// 测试Bean作用域输出

import com.demo.controller.BeanScopesControllerA;
import com.demo.controller.BeanScopesControllerB;
import com.demo.controller.BeanScopesControllerC;
import com.demo.controller.BeanScopesControllerD;
import com.demo.model.User;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class AppScope {
    public static void main(String[] args) {
        // 1. 获取Spring对象
        ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");

        // 2. 获取Bean对象
        BeanScopesControllerC bscC = context.getBean("beanScopesControllerC", BeanScopesControllerC.class);
        BeanScopesControllerD bscD = context.getBean("beanScopesControllerD",BeanScopesControllerD.class);

        // 3. 使用Bean
        System.out.println("用户C是对name进行了修改：" + bscC.getUser());
        System.out.println("用户D是直接打印的：" + bscD.getUser());

    }
}
